﻿@using OSBIDE.Library.Models
@using OSBIDE.Library.Events
@using OSBIDE.Web.Models
@using OSBIDE.Web.Models.ViewModels
@model AssignmentsViewModel
@{
    ViewBag.Title = "Assignment List";
}
<h1>Submissions for @Model.CurrentAssignmentName</h1>
@using (Html.BeginForm("Index", "Assignment", FormMethod.Get))
{
    <select name="assignmentName">
        @foreach (string option in Model.AssignmentNames)
        {
            string selected = "";
            if (option == Model.CurrentAssignmentName)
            {
                selected = "selected = \"selected\"";
            }
            <option @Html.Raw(selected) value="@option">@option</option>
        }
    </select>
    <input type="submit" value="View Submissions" />
    <img class="submit-loading" src="~/Content/icons/loading.gif" title="loading" alt="loading" />
}
<br />
<table id="subscriptions-table">
    <thead>
        <tr>
            <th>Student</th>
            <th>Date Received</th>
            <th>&nbsp;</th>
        </tr>
    </thead>
    @foreach (SubmitEvent submit in Model.Assignments)
    {
        <tr>
            <td>@submit.EventLog.Sender.FullName</td>
            <td>
                <time 
                class="utc-time"
                datetime="@Helpers.DateAsUnixTime(submit.EventLog.DateReceived)" 
                data-original-date="@Helpers.RawDate(submit.EventLog.DateReceived)" 
                data-date-format="MM/DD/YYYY hh:mm A">
                @submit.EventLog.DateReceived.ToString("MM/dd @ hh:mmtt") (UTC)
            </time>
                </td>
            <td>@Html.ActionLink("Download", "DownloadSingle", new { id = submit.EventLogId }, new { })</td>
        </tr>
    }
    <tr>
        <td colspan="3">
            @Html.ActionLink("Download All", "Download", new { assignmentName =  Model.CurrentAssignmentName}, new { })
        </td>
    </tr>
</table>
